//
//  MYFootView.swift
//  swift2.0项目开始
//
//  Created by 龚昕炜 on 16/8/1.
//  Copyright © 2016年 龚昕炜. All rights reserved.
//

import UIKit

class MYFootView: UIView {
    
    /** 传入数据模型 */
    var footerViewModel: MYHomeCellViewModel? {
        
        didSet{
            retweetButton.setTitle(footerViewModel?.retweet_String, forState: .Normal)
        }
    }
    
    /** 重写构造方法 */
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setUpUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /** 添加约束子控件 */
    private func setUpUI() {
    
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(goodButton)
        
        /** 约束 */
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(commentButton.snp_width)
        }
        
        commentButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.top.equalTo(self.snp_top)
            make.right.equalTo(goodButton.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        goodButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.right.equalTo(self.snp_right)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(commentButton.snp_width)
        }
        
    }

    /** 懒加载控件 */
    /** 转发按钮 */
    private lazy var retweetButton: UIButton = {
        
        let button = UIButton(type: UIButtonType.Custom)
        
        button.setImage(UIImage(named: ""), forState: .Normal)
        
        button.setTitle("转发", forState: .Normal)
        
        button.setTitleColor(UIColor.lightGrayColor(), forState: .Normal)
        
        button.titleLabel?.font = UIFont.systemFontOfSize(14)
        
        return button
    }()
    
    /** 评论按钮 */
    private lazy var commentButton: UIButton = {
    
        let button = UIButton(type: UIButtonType.Custom)
        
        button.setImage(UIImage(named: ""), forState: .Normal)
        
        button.setTitle("评论", forState: .Normal)
        
        button.setTitleColor(UIColor.lightGrayColor(), forState: .Normal)
        
        button.titleLabel?.font = UIFont.systemFontOfSize(14)
        
        return button
    }()
    
    /** 点赞按钮 */
    private lazy var goodButton: UIButton = {
        
        let button = UIButton(type: UIButtonType.Custom)
        
        button.setImage(UIImage(named: ""), forState: .Normal)
        
        button.setTitle("点赞", forState: .Normal)
        
        button.setTitleColor(UIColor.lightGrayColor(), forState: .Normal)
        
        button.titleLabel?.font = UIFont.systemFontOfSize(14)
        
        return button
    }()

}
